import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Response} from '@angular/http';
import { map } from 'rxjs/operators';

@Injectable()
export class TaskListService {

    constructor(private http: HttpClient) { }
    /** 获取当前参与者任务列表 */
    getTaskListDetailTabs(taskListGroupId: number, systemUrl: string) {
        return this.http.get('/'+systemUrl+'/api/tasklist/part/listbygroup?taskListGroupId=' + taskListGroupId).pipe(
            map((res: Response) => res['data'])
        )
    }

    /** 获取菜单项操作按钮 */
    loadTaskListMenu(taskListId: number, actDefId: number, poz: number = 1, actId: number = 0, systemUrl: string) {
        return this.http.get('/'+systemUrl+'/api/tasklist/menu/listbypart?taskListId=' + taskListId + "&actDefId=" + actDefId + "&poz=" + poz + "&actId=" + actId).pipe(
            map((res: Response) => res['data'])
        )
    }
    /** 获取可见TabDetail信息 */
    loadTaskListTab(taskListId: number, actDefId: number, systemUrl: string) {
        return this.http.get('/'+systemUrl+'/api/tasklist/tab/listbypart?taskListId=' + taskListId + "&actDefId=" + actDefId).pipe(
            map((res: Response) => res['data'])
        )
    }

    /** 获取表头信息 */
    loadTaskListFields(taskListId, systemUrl: string) {
        return this.http.get('/'+systemUrl+'/api/tasklist/fields/list?taskListId=' + taskListId).pipe(
            map((res: Response) => res['data'])
        )
    }

    /** 获取查询条件字段 */
    loadTaskListSearchFields(taskListId, systemUrl: string) {
        return this.http.get('/'+systemUrl+'/api/tasklist/fields/listsearch?taskListId=' + taskListId).pipe(
            map((res: Response) => res['data'])
        )
    }

    /** 获取案卷箱数据 */
    searchTaskListData(params, systemUrl: string) {
        return this.http.post('/'+systemUrl+'/api/tasklist/search', params).pipe(
            map((res: Response) => res['data'])
        )
    }

}
